package MF1DSolver;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import jmeshless.NewOkCancelDialog;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import syntaxanalyser.PostfiksX;
import FEMShapeFunction1D.FEMShapeFunction1D1;
import HashMatrix2.HashMatrix2;
import Integration.GaussQuadrature;
import Integration.IFunction1D;
import Integration.derivavty;
import MathLib.HashMatrix.Gauss;
import MathLib.HashMatrix.HashMatrix;
import MeshlessShapeFunctions.JGaussian;
import MeshlessShapeFunctions.JMeshlessInterpolationFunction1D;
import MeshlessShapeFunctions.Particle;

	public class solverGLS {

		/**
		 * @param args
		 */
		protected ArrayList<Particle> NodeList;
	    protected ArrayList<JMeshlessInterpolationFunction1D> ListOfShapeFunction;
	    protected HashMatrix A;
	    protected ArrayList<Double> Bmf;
	    protected double[] b;

	    String pString="1";
	    String wString="0";
	    String qString="10";
	    String fString="100";

	        IFunction1D p;
	        IFunction1D w;
	        IFunction1D q;
	        IFunction1D f;


	    double left;
	    double right;

	    boolean DirihetA;
	    double AVal;
	    boolean DirihetB;
	    double BVal;

	    protected GaussQuadrature gau;   
	    
		public static void main(String[] args) {
			double b = 1;
			double a = 0;
			int n = 20;
			
			ArrayList<Particle> ls1D = new ArrayList<Particle>();
	        final ArrayList<JMeshlessInterpolationFunction1D> MeshlessShapeList = new ArrayList<JMeshlessInterpolationFunction1D>();
	        double h = (b-a)/(double)n;
	        double rho = 2.1*h;
	        for (int i = 0; i <=n; i++) {
	            ls1D.add(new Particle(a+h*i, 0, i));
	            ls1D.get(ls1D.size()-1).setRho(rho);
	            MeshlessShapeList.add(new JMeshlessInterpolationFunction1D(1, a+i*h, rho, new JGaussian(rho)));
	        }
			
	        XYSeriesCollection col = new XYSeriesCollection();
	        for (Iterator<JMeshlessInterpolationFunction1D> it = MeshlessShapeList.iterator(); it.hasNext();) {
	    		JMeshlessInterpolationFunction1D jm = (JMeshlessInterpolationFunction1D) it.next();
	    		jm.setNodeList(ls1D);
	    		double x1 = 0.0;
	    		 	XYSeries series = new XYSeries("", true, true);
	    	        while(x1<=1.0001){
	    	            double tmp1 = jm.calculate(x1);
	    	            series.add(x1,tmp1);
	    	            x1+=0.002;
	    	        }
	    	        col.addSeries(series);
	    	}
	        NewOkCancelDialog dialog = new NewOkCancelDialog(null, false, col);
	        dialog.setLocationRelativeTo(null);
	        dialog.setVisible(true);
	        
	        
	        
	        solverGLS solver = new solverGLS();
	        solver.setfString("100");
	        //solver.setwString("-"+w);
	        solver.setwString("100");
	        solver.setqString("0");
	        solver.setpString("1");
	        solver.setAVal(0);
	        solver.setBVal(0);
	        solver.setDirihetA(true);
	        solver.setDirihetB(true);
	        solver.setRight(b);
	        solver.setLeft(a);

	        solver.setListOfShapeFunction(MeshlessShapeList);
	        solver.setNodeList(ls1D);


	        solver.generate();
	        final double[] res = solver.solvePenalty();        


	        XYSeries series1 = new XYSeries("розвязок методом штрафу", true, true);
	        double x = 0;
	        while(x<=1.0001){
	            double tmp = 0.0;
	            for (int j = 0; j <res.length; j++) {
	                tmp+= MeshlessShapeList.get(j).calculate(x)*res[j];
	            }
	            series1.add(x,tmp);
//	            System.out.println(x+"\t\t"+tmp);
	            x+=0.0001;
	        }

	        NewOkCancelDialog dialog1 = new NewOkCancelDialog(null, false, new XYSeriesCollection(series1));
	        dialog1.setLocationRelativeTo(null);
	        //dialog.setUndecorated(true);
	        dialog1.setVisible(true);


		}
		
		public solverGLS() {
			gau = new GaussQuadrature(50);
		}

	    public void generate(){

	        p = new IFunction1D() {

	            public double calculate(double x) {
	                try {
	                    return PostfiksX.Calculate(pString, x);
	                } catch (Exception ex) {
	                    Logger.getLogger(MF1DSolver.class.getName()).log(Level.SEVERE, null, ex);
	                }
	                return 0;
	            }

	            public double calculateDerivaty(double x) {
	            	double h = 0.0001;
	            	return ( calculate(x+h) - calculate(x-h)) / h/2.0;
	            }
	        };
	        w = new IFunction1D() {

	            public double calculate(double x) {
	                try {
	                    return PostfiksX.Calculate(wString, x);
	                } catch (Exception ex) {
	                    Logger.getLogger(MF1DSolver.class.getName()).log(Level.SEVERE, null, ex);
	                }
	                return 0;
	            }

	            public double calculateDerivaty(double x) {
	            	double h = 0.0001;
	            	return ( calculate(x+h) - calculate(x-h)) / h/2.0;
	            }
	        };
	        q = new IFunction1D() {

	            public double calculate(double x) {
	                try {
	                    return PostfiksX.Calculate(qString, x);
	                } catch (Exception ex) {
	                    Logger.getLogger(MF1DSolver.class.getName()).log(Level.SEVERE, null, ex);
	                }
	                return 0;
	            }

	            public double calculateDerivaty(double x) {
	            	double h = 0.0001;
	            	return ( calculate(x+h) - calculate(x-h)) / h/2.0;
	            }
	        };
	        f = new IFunction1D() {

	            public double calculate(double x) {
	                try {
	                    return PostfiksX.Calculate(fString, x);
	                } catch (Exception ex) {
	                    Logger.getLogger(MF1DSolver.class.getName()).log(Level.SEVERE, null, ex);
	                }
	                return 0;
	            }

	            public double calculateDerivaty(double x) {
	                throw new UnsupportedOperationException("Not supported yet.");
	            }
	        };


	        ArrayList<ArrayList<Particle>> ParticleSupport = generateParticleSupport();
	        for (int i = 0; i < ParticleSupport.size(); i++) {
	            ListOfShapeFunction.get(i).setNodeList(ParticleSupport.get(i));
	        }

	        A = new HashMatrix(HashMatrix2.ARRAY_TYPE, NodeList.size());
	        b = new double[NodeList.size()];        
	        
	        for (int i = 0; i < ParticleSupport.size(); i++) {
	            ArrayList<Particle> arrayList = ParticleSupport.get(i);
	            JMeshlessInterpolationFunction1D phi1=(ListOfShapeFunction.get(i));
	            for (int j = 0; j < arrayList.size(); j++) {
	            	JMeshlessInterpolationFunction1D phi2=(ListOfShapeFunction.get(arrayList.get(j).getNumber()));
	                A.setValue(i, arrayList.get(j).getNumber(), this.generateElement(phi1,phi2));
	            }
	            //for (int j = 0; j < ParticleSupport.size(); j++) {
	            //    gen.setPhi2(ListOfShapeFunction.get(j));
	            //    gen.update();
	            //    A.setValue(i, j, K*gen.generateKeElement() + convec*gen.generateMeElement() + Pekle*gen.generatePeElement());
	            //}
	                b[i]= this.generateFeElement(phi1);


	        }
	    }

	    private double generateElement(final JMeshlessInterpolationFunction1D phi1, final JMeshlessInterpolationFunction1D phi2){
	    	double ab = 0.0;
	    	double bb = 0.0;
	    	
	    	ab = Math.max(phi1.getXii()-phi1.getRho(), phi2.getXii()-phi2.getRho());
	        ab = Math.max(ab, left);
	        bb = Math.min(phi1.getXii()+phi1.getRho(), phi2.getXii()+phi2.getRho());
	        bb = Math.min(right, bb);
	    	
	    	return gau.justGauss(ab, bb, new IFunction1D() {
				
				@Override
				public double calculateDerivaty(double x) {
					// TODO Auto-generated method stub
					return 0;
				}
				
				@Override
				public double calculate(double x) {
			        //Pe = a*h/(2*nu);
//					double h = 1.0/10.0* 2.1 * 2;
					double h = solverSUPG.hhh * 2 / solverSUPG.param;
			        double Pe = p.calculate(x)*h/2/w.calculate(x);
			        //alfa = coth(Pe)-1/Pe; 
			        double alpha = Math.cosh(Pe)/Math.sinh(Pe)-1/Pe;
			        //tau = alfa*h/(2*a);
			        double tau = alpha*h/(2*p.calculate(x));
			        if(solverSUPG.tauOther>-100){
			        	tau = solverSUPG.tauOther;
			        }
			        
					double p1 = phi1.calculate(x);
					double p1p = phi1.calculateDerivaty(x);
					double p1pp = phi1.calculateSecondDerivaty(x);
	            	double p2 = phi2.calculate(x);
	            	double p2p = phi2.calculateDerivaty(x);
	            	double p2pp = phi2.calculateSecondDerivaty(x);
	            	double p2ppp = (p2pp - phi2.calculateSecondDerivaty(x-0.001))/0.001;
	            	
	                return p1*(p2 + tau * (p.calculate(x)*p2pp + w.calculate(x)*p2p + q.calculate(x)*p2) )*q.calculate(x) + // reaction 
	                p1p*(p2p + tau * (p.calculateDerivaty(x)*p2pp + w.calculateDerivaty(x)*p2p + q.calculateDerivaty(x)*p2 +   p.calculate(x)*p2ppp + w.calculate(x)*p2pp + q.calculate(x)*p2p) )*p.calculate(x) + //diffusion
	                (p2p)*(p1+tau * (p.calculate(x)*p1pp + w.calculate(x)*p1p + q.calculate(x)*p1))*w.calculate(x); // advection
				}
			});
	    }
		private double generateFeElement(final JMeshlessInterpolationFunction1D phi1){
			
			double tmpb = Math.min(right, phi1.getXii()+phi1.getRho());
	        double tmpa = Math.max(phi1.getXii()-phi1.getRho(), left);
	        return gau.justGauss(tmpa, tmpb, new  IFunction1D() {

	            public double calculate(double x) {
	            	//Pe = a*h/(2*nu);
//	            	double h = 1.0/10.0* 2.1 * 2;
	            	double h = solverSUPG.hhh * 2 / solverSUPG.param;
			        double Pe = p.calculate(x)*h/2/w.calculate(x);
			        //alfa = coth(Pe)-1/Pe; 
			        double alpha = Math.cosh(Pe)/Math.sinh(Pe)-1/Pe;
			        //tau = alfa*h/(2*a);
			        double tau = alpha*h/(2*p.calculate(x));
			        if(solverSUPG.tauOther>-100){
			        	tau = solverSUPG.tauOther;
			        }
			        
	            	double p1 = phi1.calculate(x);
	            	double p1p = phi1.calculateDerivaty(x);
	            	double p1pp = phi1.calculateSecondDerivaty(x);
	                return f.calculate(x)*(p1+tau * (p.calculate(x)*p1pp + w.calculate(x)*p1p + q.calculate(x)*p1));
	            }

	            public double calculateDerivaty(double x) {
	                throw new UnsupportedOperationException("Not supported yet.");
	            }
	        });
		}

	    public double[] solvePenalty(){

	        double MaxC = 100000000000.0;

	        if(DirihetA&&DirihetB){

	            for(int i=0;i<b.length;i++){
	                double tmp2 = ListOfShapeFunction.get(i).calculate(right);
	                double tmp1 = ListOfShapeFunction.get(i).calculate(left);
	                for(int j=0;j<b.length;j++){
	                    double val = MaxC*(tmp1*ListOfShapeFunction.get(j).calculate(left) +
	                            tmp2*ListOfShapeFunction.get(j).calculate(right));
	                    A.setValue(i, j,A.getValue(i, j)+ val);
	                }
	                b[i]+=MaxC*(BVal*tmp2+AVal*tmp1);
	            }
	        }else{
	            if(DirihetA){
	                for(int i=0;i<b.length;i++){
	                    double tmp = ListOfShapeFunction.get(i).calculate(left);
	                    for(int j=0;j<b.length;j++){
	                        A.setValue(i, j,A.getValue(i, j)+ MaxC*(tmp*ListOfShapeFunction.get(j).calculate(left)));
	                    }
	                    b[i]+=MaxC*(AVal*tmp);
	                }
	            }else{
	                for (int i = 0; i < ListOfShapeFunction.size(); i++) {
	                    JMeshlessInterpolationFunction1D jMeshlessInterpolationFunction1D = ListOfShapeFunction.get(i);
	                    b[i]+=AVal*jMeshlessInterpolationFunction1D.calculate(left);
	                }
	            }

	            if(DirihetB){

	                for(int i=0;i<b.length;i++){
	                    double tmp = ListOfShapeFunction.get(i).calculate(right);
	                    for(int j=0;j<b.length;j++){
	                        A.setValue(i, j,A.getValue(i, j)+ MaxC*(tmp*ListOfShapeFunction.get(j).calculate(right)));
	                    }
	                    b[i]+=MaxC*(BVal*tmp);
	                }
	            }else{
	                for (int i = 0; i < ListOfShapeFunction.size(); i++) {
	                    JMeshlessInterpolationFunction1D jMeshlessInterpolationFunction1D = ListOfShapeFunction.get(i);
	                    b[i]+=BVal*jMeshlessInterpolationFunction1D.calculate(right);
	                }
	            }
	        }

	        //Dirihlet a:
	        //for(int i=0;i<b.length;i++){
	        //    A.setValue(0, i,A.getValue(0, i)+ MaxC*ListOfShapeFunction.get(i).calculate(left)*ListOfShapeFunction.get(0).calculate(left));
	        //}
	        //b[0]+=0;

	        //Dirihlet b:
	        //for(int i=0;i<b.length;i++){
	        //    A.setValue(b.length-1, i,A.getValue(b.length-1, i)+ MaxC*ListOfShapeFunction.get(i).calculate(right)*ListOfShapeFunction.get(b.length-1).calculate(right));
	        //}
	        //b[b.length-1]+=0;
	        //LUFactorization lu = new LUFactorization(A);

//	        for (int i = 0; i < this.ListOfShapeFunction.size(); i++) {
//	            for (int j = 0; j < this.ListOfShapeFunction.size(); j++) {
//	                System.out.print(this.A.getValue(i, j)+"\t\t");
//	            }
//	            System.out.print("\n");
//	        }

//	        for (int i = 0; i < this.ListOfShapeFunction.size(); i++) {
////	            for (int j = 0; j < this.ListOfShapeFunction.size(); j++) {
////	                System.out.print(this.A.getValue(i, j)+"\t\t");
////	            }
//	            System.out.print(b[i]+"\n");
//	        }
//	        System.out.print("==========================================\n");

	            Gauss lu = new Gauss(A);
	        return lu.calculate(b);
	    }

	    public void generatePenalty(){

	        double MaxC = 10000000000000.0;

	        if(DirihetA&&DirihetB){

	            for(int i=0;i<b.length;i++){
	                double tmp2 = ListOfShapeFunction.get(i).calculate(right);
	                double tmp1 = ListOfShapeFunction.get(i).calculate(left);
	                for(int j=0;j<b.length;j++){
	                    A.setValue(i, j,A.getValue(i, j)+ MaxC*(tmp1*ListOfShapeFunction.get(j).calculate(left) +
	                            tmp2*ListOfShapeFunction.get(j).calculate(right)));
	                }
	                b[i]+=MaxC*(BVal*tmp2+AVal*tmp1);
	            }
	        }else{
	            if(DirihetA){
	                for(int i=0;i<b.length;i++){
	                    double tmp = ListOfShapeFunction.get(i).calculate(left);
	                    for(int j=0;j<b.length;j++){
	                        A.setValue(i, j,A.getValue(i, j)+ MaxC*(tmp*ListOfShapeFunction.get(j).calculate(left)));
	                    }
	                    b[i]+=MaxC*(AVal*tmp);
	                }
	            }else{
	                for (int i = 0; i < ListOfShapeFunction.size(); i++) {
	                    JMeshlessInterpolationFunction1D jMeshlessInterpolationFunction1D = ListOfShapeFunction.get(i);
	                    b[i]+=AVal*jMeshlessInterpolationFunction1D.calculate(left);
	                }
	            }

	            if(DirihetB){

	                for(int i=0;i<b.length;i++){
	                    double tmp = ListOfShapeFunction.get(i).calculate(right);
	                    for(int j=0;j<b.length;j++){
	                        A.setValue(i, j,A.getValue(i, j)+ MaxC*(tmp*ListOfShapeFunction.get(j).calculate(right)));
	                    }
	                    b[i]+=MaxC*(BVal*tmp);
	                }
	            }else{
	                for (int i = 0; i < ListOfShapeFunction.size(); i++) {
	                    JMeshlessInterpolationFunction1D jMeshlessInterpolationFunction1D = ListOfShapeFunction.get(i);
	                    b[i]+=BVal*jMeshlessInterpolationFunction1D.calculate(right);
	                }
	            }
	        }
	    }

	    public double[] solveLagrangeMulti(){
	        int n = A.getN();
	        HashMatrix A2=null;
	        double[] tmpb=null;
	        
	        if(DirihetA&&DirihetB){

	            A2 = new HashMatrix(HashMatrix.ARRAY_TYPE, n+2);
	            tmpb = new double[n+2];
	            double tmp = ListOfShapeFunction.get(0).calculate(left);
	            for (int i = 0; i < b.length; i++) {
	                for (int j = 0; j < b.length; j++) {
	                    A2.setValue(i, j, A.getValue(i, j));
	                }
	            }
	            for(int i=0;i<n;i++){
	                A2.setValue(n, i, ListOfShapeFunction.get(i).calculate(left)*tmp);
	                A2.setValue(i, n, ListOfShapeFunction.get(i).calculate(left)*tmp);
	                tmpb[i] = b[i];
	            }
	            tmpb[n] = tmp*AVal;

	            tmp = ListOfShapeFunction.get(ListOfShapeFunction.size()-1).calculate(right);
	            for(int i=0;i<n;i++){
	               A2.setValue(n+1, i, ListOfShapeFunction.get(i).calculate(right)*tmp);
	               A2.setValue(i, n+1, ListOfShapeFunction.get(i).calculate(right)*tmp);
	            }
	            tmpb[n+1] = tmp*BVal;

	        }else{
	            if(DirihetA){
	                A2 = new HashMatrix(HashMatrix.ARRAY_TYPE, n+1);
	                tmpb = new double[n+1];
	                for (int i = 0; i < b.length; i++) {
	                    for (int j = 0; j < b.length; j++) {
	                        A2.setValue(i, j, A.getValue(i, j));
	                    }
	                }

	                double tmp = ListOfShapeFunction.get(0).calculate(left);
	                for(int i=0;i<n;i++){
	                    A2.setValue(n, i, ListOfShapeFunction.get(i).calculate(left)*tmp);
	                    A2.setValue(i, n, ListOfShapeFunction.get(i).calculate(left)*tmp);
	                    tmpb[i] = b[i];
	                }
	                tmpb[n] = tmp*AVal;
	            }else{
	                for (int i = 0; i < ListOfShapeFunction.size(); i++) {
	                    JMeshlessInterpolationFunction1D jMeshlessInterpolationFunction1D = ListOfShapeFunction.get(i);
	                    b[i]+=AVal*jMeshlessInterpolationFunction1D.calculate(left);
	                }
	            }

	            if(DirihetB){
	                A2 = new HashMatrix(HashMatrix.ARRAY_TYPE, n+1);
	                tmpb = new double[n+1];
	                for (int i = 0; i < b.length; i++) {
	                    for (int j = 0; j < b.length; j++) {
	                        A2.setValue(i, j, A.getValue(i, j));
	                    }
	                }

	                double tmp = ListOfShapeFunction.get(ListOfShapeFunction.size()-1).calculate(right);
	                for(int i=0;i<n;i++){
	                   A2.setValue(n, i, ListOfShapeFunction.get(i).calculate(right)*tmp);
	                   A2.setValue(i, n, ListOfShapeFunction.get(i).calculate(right)*tmp);
	                }
	                tmpb[n] = tmp*BVal;
	            }else{
	                for (int i = 0; i < ListOfShapeFunction.size(); i++) {
	                    JMeshlessInterpolationFunction1D jMeshlessInterpolationFunction1D = ListOfShapeFunction.get(i);
	                    b[i]+=BVal*jMeshlessInterpolationFunction1D.calculate(right);
	                }
	            }
	        }

//	        for (int i = 0; i < A2.getN(); i++) {
//	            for (int j = 0; j < A2.getN(); j++) {
//	                System.out.print(A2.getValue(i, j)+"\t\t");
//	            }
//	            System.out.print("\n");
//	        }
	//
//	        for (int i = 0; i < this.ListOfShapeFunction.size(); i++) {
////	            for (int j = 0; j < this.ListOfShapeFunction.size(); j++) {
////	                System.out.print(this.A.getValue(i, j)+"\t\t");
////	            }
//	            System.out.print(tmpb[i]+"\n");
//	        }
//	        System.out.print("==========================================\n");


	        //LUFactorization lu = new LUFactorization(A);
	        Gauss lu = new Gauss(A2);
	        return lu.calculate(tmpb);
	    }

	    public HashMatrix getA() {
	        return A;
	    }

	    public double[] getB() {
	        return b;
	    }

	    public double getAVal() {
	        return AVal;
	    }

	    public void setAVal(double AVal) {
	        this.AVal = AVal;
	    }

	    public double getBVal() {
	        return BVal;
	    }

	    public void setBVal(double BVal) {
	        this.BVal = BVal;
	    }

	    public boolean isDirihetA() {
	        return DirihetA;
	    }

	    public void setDirihetA(boolean DirihetA) {
	        this.DirihetA = DirihetA;
	    }

	    public boolean isDirihetB() {
	        return DirihetB;
	    }

	    public void setDirihetB(boolean DirihetB) {
	        this.DirihetB = DirihetB;
	    }

	    public String getfString() {
	        return fString;
	    }

	    public void setfString(String fString) {
	        this.fString = fString;
	    }

	    public String getpString() {
	        return pString;
	    }

	    public void setpString(String pString) {
	        this.pString = pString;
	    }

	    public String getqString() {
	        return qString;
	    }

	    public void setqString(String qString) {
	        this.qString = qString;
	    }

	    public double getRight() {
	        return right;
	    }

	    public void setRight(double right) {
	        this.right = right;
	    }

	    public String getwString() {
	        return wString;
	    }

	    public void setwString(String wString) {
	        this.wString = wString;
	    }

	    public double getLeft() {
	        return left;
	    }

	    public void setLeft(double left) {
	        this.left = left;
	    }
	    

	    public ArrayList<JMeshlessInterpolationFunction1D> getListOfShapeFunction() {
	        return ListOfShapeFunction;
	    }

	    public void setListOfShapeFunction(ArrayList<JMeshlessInterpolationFunction1D> ListOfShapeFunction) {
	        this.ListOfShapeFunction = ListOfShapeFunction;
	    }

	    public ArrayList<Particle> getNodeList() {
	        return NodeList;
	    }

	    public void setNodeList(ArrayList<Particle> NodeList) {
	        this.NodeList = NodeList;
	    }
	    
	    private ArrayList<ArrayList<Particle>> generateParticleSupport(){
	        ArrayList<ArrayList<Particle>> res = new ArrayList<ArrayList<Particle>>();
	        //for (int i = 0; i < ListOfShapeFunction.size(); i++) {
	        //    ArrayList<Particle> tmp = new ArrayList<Particle>();
	        //    JMeshlessInterpolationFunction1D phi = ListOfShapeFunction.get(i);
	            /*for (int j = 0; j < i; j++) {
	            JMeshlessInterpolationFunction1D phiTMP = ListOfShapeFunction.get(j);
	            if(Math.abs(phi.getXii()-phiTMP.getXii())<(Math.abs(phi.getRho()+phiTMP.getRho()))){
	            tmp.add(new Particle(phiTMP.getXii(), 0.0, j));//TODO перевірити чи той номер вузла ні на шо не впливає .....
	            }
	            }*/
	        //    for (int j = 0; j < ListOfShapeFunction.size(); j++) {
	        //        JMeshlessInterpolationFunction1D phiTMP = ListOfShapeFunction.get(j);
	        //        if(Math.abs(phi.getXii()-phiTMP.getXii())<(Math.abs(phi.getRho()+phiTMP.getRho()))){
	        //            tmp.add(new Particle(phiTMP.getXii(), 0.0, j));//TODO перевірити чи той номер вузла ні на шо не впливає .....
	        //        }
	        //    }
	        //    res.add(tmp);
	        //}
	        //return res;
	        for (int i = 0; i < ListOfShapeFunction.size(); i++) {
	            res.add(NodeList);            
	        }
	        return res;
	    }
		

	}
